package pshop.servlet.util;

import pshop.Bestellung;
import pshop.servlet.util.Log;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

import javax.servlet.http.HttpServletRequest;

public class EmailTextUtils
{
   public static String generateBestText(Bestellung best, HttpServletRequest req)
   {
      try
      {
         URL url = new URL(req.getRequestURL().toString() + "/templates/best-email.jsp");
         BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
         String line;
         String text = "";
         while ((line = reader.readLine()) != null)
         {
            text += line;
         }
         reader.close();
         return text;
      }
      catch (Exception e)
      {
         Log.logError(e);
         return null;
      }

   }
}